import Cookies from 'js-cookie'

const tokenKey = 'access_token',
  refreshTokenKey = 'refresh_token';

export const getToken = () => {
  return Cookies.get(tokenKey)
}

export const setToken = (token,expiresTime) =>{
  console.log(token);
  let options = { path: "/"}
  if (expiresTime) options.expires = expiresTime/ 24;
  return Cookies.set(tokenKey, token,options)
}
export const removeToken = () =>{
  Cookies.remove(tokenKey)
}
export const getRefreshToken = () =>{
  return Cookies.get(refreshTokenKey)
}
export const setRefreshToken = (token,expiresTime)=>{
  let options = { path: "/"}
  if (expiresTime) options.expires = expiresTime/ 24;
  return Cookies.set(refreshTokenKey, token,options)
}
export const removeRefreshToken = () =>{
  Cookies.remove(refreshTokenKey)
}
export const setLogin = (token,refresh,expires) =>{
  setToken(token , expires)
  setRefreshToken(refresh , expires)
}
export const removeLogin = () =>{
  removeToken();
  removeRefreshToken()
}
